package com.kantboot.api.yunzhanghu.setting;

import com.kantboot.system.setting.service.ISysSettingService;
import com.yunzhanghu.sdk.base.YzhConfig;
import com.yunzhanghu.sdk.payment.PaymentClient;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.HashMap;

/**
 * 云账户配置
 */
@Service
public class ApiYunzhanghuSetting {

    @Resource
    private ISysSettingService settingService;

    /**
     * 获取云账户配置
     */
    public YzhConfig getYzhConfig() {
        HashMap<String, String> yzhMap = settingService.getMapByGroupCode("yunzhanghu");
        YzhConfig config = new YzhConfig();
        config.setDealerId(yzhMap.get("dealerId"));
        config.setBrokerId(yzhMap.get("brokerId"));
        config.setYzhAppKey(yzhMap.get("yzhAppKey"));
        config.setYzh3DesKey(yzhMap.get("yzh3DesKey"));
        config.setYzhRsaPrivateKey(yzhMap.get("yzhRsaPrivateKey"));
        config.setYzhRsaPublicKey(yzhMap.get("yzhRsaPublicKey"));
        config.setYzhUrl(yzhMap.get("yzhUrl"));
        config.setSignType(YzhConfig.SignType.RSA);
        return config;
    }

    /**
     * 获取云账户支付客户端
     */
    public PaymentClient getPaymentClient() {
        return new PaymentClient(getYzhConfig());
    }

}
